var express = require('express');
const qqMusic = require('qq-music-api');
var router = express.Router();
router.get('/user/setCookie', function(req, res, next) {
    qqMusic.api('user/setCookie', { ...req.query,},req.cookies)
        .then((r) => {
            res.send({data:r,code:200})
        })
        .catch(r => res.send(r.data))
});

router.get('/recommend/playlist/u', function(req, res, next) {
    qqMusic.api('recommend/playlist/u', { ...req.query,},req.cookies)
        .then((r) => {
            res.send({data:r,code:200})
        })
        .catch(r => res.send(r.data))
});

router.get('/songlist', function(req, res, next) {
    qqMusic.api('songlist', { ...req.query,},req.cookies)
        .then((r) => {
            res.send({data:r,code:200})
        })
        .catch(r => res.send(r.data))
});
router.get('/song/urls', function(req, res, next) {
    qqMusic.api('song/urls', { ...req.query,},req.cookies)
        .then((r) => {
            res.send({data:r,code:200})
        })
        .catch(r => res.send({data:r,code:200}))
});
router.get('/album', function(req, res, next) {
    qqMusic.api('album', { albummid: req.query.albummid })
        .then((r) => {
            res.send({data:r,code:200})
        })
        .catch(r => res.send(r.data))
});
router.get('/user/detail', function(req, res, next) {
    qqMusic.api('user/detail', { ...req.query,},req.cookies)
        .then((r) => {
            res.send({data:r,code:200})
        })
        .catch(r => res.send(r.data))
});
router.get('/search', function(req, res, next) {
    console.log(req.query)
    qqMusic.api('search', { ...req.query,},req.cookies)
        .then((r) => {
            res.send({data:r,code:200})
        })
        .catch(r => res.send(r.data))
});
router.get('/singer/album', function(req, res, next) {
    console.log(req.query)
    qqMusic.api('singer/album',{ ...req.query,},req.cookies)
        .then((r) => {
            res.send({data:r,code:200})
        })
        .catch(r => res.send(r.data))
});
router.get('/album/songs', function(req, res, next) {
    console.log(req.query)
    qqMusic.api('album/songs', { ...req.query,},req.cookies)
        .then((r) => {
            res.send({data:r,code:200})
        })
        .catch(r => res.send(r.data))
});
router.get('/songlist/category', function(req, res, next) {
    console.log(req.query)
    qqMusic.api('songlist/category', { ...req.query,},req.cookies)
        .then((r) => {
            res.send({data:r,code:200})
        })
        .catch(r => res.send(r.data))
});
router.get('/songlist/list', function(req, res, next) {
    console.log(req.query)
    qqMusic.api('songlist/list', { ...req.query,},req.cookies)
        .then((r) => {
            res.send({data:r,code:200})
        })
        .catch(r => res.send(r.data))
});

router.get('/top/category', function(req, res, next) {
    console.log(req.query)
    qqMusic.api('top/category', { ...req.query,},req.cookies)
        .then((r) => {
            res.send({data:r,code:200})
        })
        .catch(r => res.send(r.data))
});
router.get('/top', function(req, res, next) {
    console.log(req.query)
    qqMusic.api('top', { ...req.query,},req.cookies)
        .then((r) => {
            res.send({data:r,code:200})
        })
        .catch(r => res.send(r.data))
});
router.get('/singer/category', function(req, res, next) {
    console.log(req.query)
    qqMusic.api('singer/category', { ...req.query,},req.cookies)
        .then((r) => {
            res.send({data:r,code:200})
        })
        .catch(r => res.send(r.data))
});
router.get('/singer/list', function(req, res, next) {
    console.log(req.query)
    qqMusic.api('singer/list', { ...req.query,},req.cookies)
        .then((r) => {
            res.send({data:r,code:200})
        })
        .catch(r => res.send(r.data))
});

router.get('/lyric', function(req, res, next) {
    console.log(req.query)
    qqMusic.api('lyric', { ...req.query,},req.cookies)
        .then((r) => {
            res.send({data:r,code:200})
        })
        .catch(r => res.send(r.data))
});


module.exports = router;